//
//  UIView+Extension.m
//  BonweBuy
//
//  Created by liuxin on 2020/2/25.
//  Copyright © 2020 liuxin. All rights reserved.
//

#import "UIView+Extension.h"


@implementation UIView (Extension)

- (void)setXl_x:(CGFloat)xl_x
{
    CGRect frame = self.frame;
    frame.origin.x = xl_x;
    self.frame = frame;
    
}
-(CGFloat)xl_x{
    return self.frame.origin.x;
}
-(void)setXl_y:(CGFloat)xl_y
{
    CGRect frame = self.frame;
    frame.origin.y = xl_y;
    self.frame = frame;
    
}
-(CGFloat)xl_y
{
    return self.frame.origin.y;
}

- (void)setXl_width:(CGFloat)xl_width
{
    CGRect frame = self.frame;
    frame.size.width = xl_width;
    self.frame = frame;
}
- (CGFloat)xl_width
{
    return self.frame.size.width;
}


- (void)setXl_height:(CGFloat)xl_height
{
    CGRect frame = self.frame;
    frame.size.height = xl_height;
    self.frame = frame;
}

- (CGFloat)xl_height
{
    return self.frame.size.height;
}

- (void)setXl_bottom:(CGFloat)xl_bottom
{
    CGRect frame = self.frame;
    frame.origin.y  = xl_bottom - self.frame.size.height;
    self.frame = frame;
}
- (CGFloat)xl_bottom
{
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setXl_right:(CGFloat)xl_right
{
    CGRect frame = self.frame;
    frame.origin.x = xl_right - self.frame.size.width;
    self.frame = frame;
}

- (CGFloat)xl_right
{
    return self.frame.size.width + self.frame.origin.x;
}


- (void)setXl_centerX:(CGFloat)xl_centerX
{
    CGPoint center = self.center;
    center.x = xl_centerX;
    self.center = center;
}

- (CGFloat)xl_centerX
{
    return self.center.x;
}

- (void)setXl_centerY:(CGFloat)xl_centerY
{
    CGPoint center = self.center;
    center.y = xl_centerY;
    self.center = center;
}

- (CGFloat)xl_centerY
{
    return self.center.y;
}


- (void)setXl_size:(CGSize)xl_size
{
    CGRect frame = self.frame;
    frame.size = xl_size;
    self.frame = frame;
}

- (CGSize)xl_size
{
    return self.frame.size;
}

- (void)setXl_origin:(CGPoint)xl_origin
{
    CGRect frame = self.frame;
    frame.origin = xl_origin;
    self.frame = frame;
}

- (CGPoint)xl_origin
{
    return self.frame.origin;
}

- (void)addLineWithFrame:(CGRect)frame{
    [self addLineWithFrame:frame color:[UIColor colorWithRed:248 green:248 blue:248 alpha:1.00f]];
}

- (void)addLineWithFrame:(CGRect)frame color:(UIColor *)color{
    CALayer *layer = [CALayer layer];
    layer.frame = frame;
    layer.backgroundColor = color.CGColor;
    [self.layer addSublayer:layer];
}

-(void)setlayerCornerRadius:(CGFloat)cornerRadius corners:(UIRectCorner)corners{
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
    CAShapeLayer * maskLayer = [[CAShapeLayer alloc]init];
    maskLayer.frame =  self.bounds;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;
}

@end
